<template>
  <div>
    <h5>
      <ul>
        <li v-for="(item, index) in arr" :key="index">
          {{ item }}
          <button @click="san(index)">删除</button>
        </li>
      </ul>
      <button @click="fn">生成</button>
    </h5>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [5, 7, 1],
    };
  },
  methods: {
    fn() {
      const keys = parseInt(Math.random() * 10);
      console.log(keys);
      this.arr.push(keys);
    },
    san(ind) {
      this.arr.splice(ind, 1);
    },
  },
};
</script>

<style>
h5 {
  width: 200px;
  height: 200px;
  border: 1px solid red;
}
ul {
  margin-top: 30px;
}
</style>